package com.pym.Service.ServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.pym.pojo.Book;
import com.pym.Mapper.BookMapper;
import com.pym.Service.BookService;

import java.util.List;

@Service
public class BookServiceImpl implements BookService{

    @Autowired
    private BookMapper bookMapper;

    @Override
    public boolean deleteByPrimaryKey(Integer id) {
        return bookMapper.deleteByPrimaryKey(id);
    }

    @Override
    public boolean insert(Book record) {
        return bookMapper.insert(record);
    }
    @Override
    public int insertSelective(Book record) {
        return bookMapper.insertSelective(record);
    }

    @Override
    public Book selectByPrimaryKey(Integer id) {
        return bookMapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean updateByPrimaryKeySelective(Book record) {
        return bookMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Book record) {
        return bookMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Book> findBookAll() {
        return bookMapper.findBookAll();
    }

    @Override
    public PageInfo<Book> finBooAllByCurrentPageAndPageSize(int CurrentPage, int PageSize) {
        PageHelper.startPage(CurrentPage,PageSize);
        List<Book> bookAll = bookMapper.findBookAll();
        return new PageInfo<>(bookAll);
    }

    @Override
    public List<Book> finBooAllByCurrentPageAndPageSizeAndBook(Book book) {
        return bookMapper.finBooAllByCurrentPageAndPageSizeAndBook(book);
    }

}
